#include "ImageCamera.h"

ImageCamera::ImageCamera():ImageBase(){
    
    //openDevice();
    flag = true;

}
ImageCamera::ImageCamera(unsigned int width,unsigned int height):ImageBase(width, height){

    ImageCamera();
}
ImageCamera::~ImageCamera() {
    closeDevice();
}


int ImageCamera::getImage(Mat &image) {



     cap >> image;

     //image = imread("./10054.jpg");

     if (image.empty()) {
         cerr << "ERROR! blank frame grabbed\n";
         return -1;
     }else{
        cout<< "getImage read image success\n";
     }

     return 0;

}

int ImageCamera::openDevice() {

    cap.open(0);
	if (!cap.isOpened()) {
         cerr << "ERROR! Unable to open camera\n";
         return -1;
     }else{
        cout<< "open camera success\n";
     }

     return 0;
}
int ImageCamera::closeDevice() {
    cap.release();
    cout<< "close camera\n";
	
	return 0;
}
